﻿import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException, ClassNotFoundException {
        //新建对象student
        Student stu1 = new Student(100, "zhang");

        //序列化成二进制文件
        ObjectOutputStream oo = new ObjectOutputStream(new FileOutputStream(new File("d:\\a.txt")));
        oo.writeObject(stu1);

        //反序列化成对象
        ObjectInputStream oi = new ObjectInputStream(new FileInputStream(new File("d:\\a.txt")));
        Student stu2 = (Student) oi.readObject();
        System.out.println(stu2.toString());

    }

}
